var Mqtt = require( "mqtt" )

var  mqtt = Mqtt.connect( "mqtt://111.231.108.101" )
//var  mqtt = Mqtt.connect( "ws://127.0.0.1:9009" )

mqtt.on( "connect" , (msg )=> {
    console.log( "connect success" );

    mqtt.subscribe( "wangsheng/test" )

    setTimeout( ()=> { mqtt.publish( "wangsheng/test" , "xxxxxx" );}, 100);
});

mqtt.on( "error", ( error )=> { 
  console.log( "error: " , error );
});

mqtt.on( "message" , ( topic, payload, packet )=> {
  console.log( "get message: ", payload  );
  console.log( "toString: " , payload.toString() )
  console.log( topic, payload, packet )
});

console.log( "-----------connecting " )
